import CrudService from '../global/CrudService'

let instance = null

// 后端路径
const prefix = '/rptTask'

class Service extends CrudService {
	constructor() {
		super(prefix)
		this.getListPath = `${prefix}/queryTaskList`
		this.addPath     = `${prefix}/insertTask`
		this.deletePath  = `${prefix}/deleteTask`
		this.updatePath  = `${prefix}/updateTask`
		return instance || this
	}
	
	static getInstance() {
		if (!instance) {
			instance = new Service()
		}
		return instance
	}
	
	queryTaskList_sz_unpagi = async (model) => {
		const result = await this.get(`${prefix}/queryTaskList_sz_unpagi`, model)
		return Array.isArray(result) && result.map(item => ({
			...item,
			key  : item.task_code,
			value: item.task_name
		}))
	}
}

export default Service.getInstance()
